package com.le.tester.javaThink.fifth.chapter14_StreamingProgramming;

import java.util.Random;
import java.util.SortedSet;
import java.util.TreeSet;

/**
 * 描述：重要的随机流，声明式的编程
 */
public class ImperativeRandoms {
    public static void main(String[] args) {
        //random num new Object
        Random random = new Random(47);
        //sorted
        SortedSet<Integer> treeSet = new TreeSet<>();
        //loop 7
        while (treeSet.size() < 7) {
            //random range is [0-20)
            int i = random.nextInt(20);
            if (i < 5) {
                //less than 5 no add()
                // no less than 5  add()
                //满足条件之后，跳出本次的循环，进入到下一次的循环条件的判断
                continue;
            }
            treeSet.add(i);
        }
        System.out.println(treeSet);
    }

}
